<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;

class Station extends Model
{

	use Notifiable;
    //
	protected $table = 'station';

	protected $guarded=[];
//	protected $fillable =['id','name','standard_hour','standard_day','hour_salary','comment','status','company_id','is_store'];

	/**
	 * 数组应该隐藏的属性
	 *
	 * @var array
	 */
	protected $hidden = [
		'remember_token',
	];




//	列表
	public function lists($where){

		$res=$this->where(function ($query) use($where){
			$query->where(['company_id'=>$where['company_id']]);
			if($where['name'] !=null){
				$query->where('name','like','%'.$where['name'].'%');
			}
			if($where['status'] !=null){
				$query->where('status',$where['status']);
			}
			if($where['start_time'] !=null){
				$query->where('created_at','>',$where['start_time']);
			}
			if($where['end_time'] !=null){
				$query->where('created_at','<',$where['end_time']);
			}
		})->with('pub_status')->paginate(config('app.page'));

		return $res;
	}

	public function lists_($where){
		$res=$this->where(function ($query) use($where){
			$query->where(['company_id'=>$where['company_id'],'status'=>1,'is_store'=>1]);
		})->with('pub_status')->get();

		return $res;
	}

//	查询岗位的详细信息
	public function station_desc($id){
		return $this->where(['id'=>$id])->first();
	}


	public function pub_status(){
		return $this->hasOne('App\Model\Pub_status','pub_id','status');
	}
}
